package com.example.checkqufuface.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.checkqufuface.R;
import com.example.checkqufuface.bean.CheckShowBaseBean;

import java.util.List;

public class TicketStatueCheckResultAdapter extends RecyclerView.Adapter<TicketStatueCheckResultAdapter.ViewHolder> {

    private Context context;
    private List<CheckShowBaseBean> dataList;

    public TicketStatueCheckResultAdapter(Context context, List<CheckShowBaseBean> checkResultList) {
        this.context = context;
        dataList = checkResultList;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.widget_ticket_result_check, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

        holder.tvId.setText((position + 1) + "");
        holder.tvNumber.setText(dataList.get(position).getAmount() + "");
        holder.tvName.setText(dataList.get(position).getUserName());
        holder.tvMeation.setText(dataList.get(position).getTerminalName());
        holder.tvTime.setText(dataList.get(position).getCreatedDate());

    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private final TextView tvId;
        private final TextView tvNumber;
        private final TextView tvName;
        private final TextView tvMeation;
        private final TextView tvTime;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);

            tvId = itemView.findViewById(R.id.tv_ticket_result_id);
            tvNumber = itemView.findViewById(R.id.tv_ticket_result_number);
            tvName = itemView.findViewById(R.id.tv_ticket_result_name);
            tvMeation = itemView.findViewById(R.id.tv_ticket_result_meation);
            tvTime = itemView.findViewById(R.id.tv_ticket_result_time);
        }
    }
}
